home *** CD-ROM | disk | FTP | other *** search
- unit Packtbl;
-
- interface
-
- uses
-
- DBIProcs, DBIErrs, DBITypes, DB, DBTables, sysutils;
-
- procedure PackTable(const tbl : TTable);
-
- implementation
-
- procedure PackTable(const tbl : TTable);
-
- var
-
- dbResult : DBIResult;
-
- hDB : hDBIDb;
-
- hCursor : hDBICur;
-
- pszTablename : PChar;
-
- pszDriverType : PChar;
-
- bRegenIdxs : Boolean;
-
- StoreExcl : boolean;
-
- StoreActive : boolean;
-
- begin
-
- StoreExcl := tbl.exclusive;
-
- StoreActive := tbl.Active;
-
- try
-
- try
-
- tbl.open;
-
- hDB := tbl.DBHandle;
-
- tbl.close;
-
- tbl.exclusive := true;
-
- except
-
- on E : Exception do
-
- raise Exception.create(
-
- 'Error locking table for exclusive access:'+
-
- E.message);
-
- end;
-
- pszTableName := StrAlloc(25);
-
- StrPCopy(pszTableName, tbl.tablename);
-
- pszDriverType := StrAlloc(25);
-
- StrPCopy(pszDriverType, 'DBase');
-
- bRegenIdxs := true;
-
- dbResult := DBiPackTable(hDB, tbl.handle,
-
- pszTableName, pszDriverType, bRegenIdxs);
-
- if dbResult <> DBIERR_NONE then
-
- raise EDBEngineError.create(dbResult);
-
- finally
-
- tbl.exclusive := StoreExcl;
-
- tbl.active := StoreActive;
-
- end;
-
- end;